Skip to content

feat(cli): support opt-in bundleDependencies in zero-yaml compile#6706

Closed
sahilnyk wants to merge 5 commits into
NangoHQ:masterfrom
sahilnyk:feat/compile-bundle-dependencies
Closed

feat(cli): support opt-in bundleDependencies in zero-yaml compile#6706
sahilnyk wants to merge 5 commits into
NangoHQ:masterfrom
sahilnyk:feat/compile-bundle-dependencies

Conversation

@sahilnyk

@sahilnyk sahilnyk commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Problem

Thanks to @diegoleme for reporting this in #6425 and proposing the bundleDependencies approach.

In a monorepo, a sync often needs to reuse an internal workspace package (like @repo/shared for helpers or types). Right now nango compile won't allow it. From the issue:

the helper has to be manually copy-pasted into the integrations folder and kept in sync by hand, which silently drifts from the source of truth

Two things cause it:

  1. esbuild marks every non-relative import as external, so @repo/shared never gets bundled and is missing in the sandbox.
  2. The import check throws disallowed_import for anything outside the hardcoded allowlist.

Solution

Add an opt-in bundleDependencies array to the project's package.json:

{ "bundleDependencies": ["@repo/shared"] }

Packages in that list skip the disallowed_import check and get inlined into the compiled .cjs instead of externalized. Subpaths like @repo/shared/utils match too. Safe for the sandbox
since the code is inlined at build time, and nothing changes when the field is absent.

Node built-ins are rejected. Under platform: 'node' esbuild leaves built-ins external, so listing something like "fs" would let a script reach the sandbox and skip the allowlist. They're
blocked both when the config is read and if one reaches esbuild resolution.

Closes #6425

Testing

Run: npx vitest --config ./vite.cli.config.ts run

6 tests, all run locally and passing:

  • Rejects a workspace import when it's not opted in (fails with disallowed_import)
  • Inlines a workspace import when opted in
  • Matches subpaths like @repo/shared/utils
  • Compiled .cjs on disk has the inlined code, no leftover require("@repo/shared")
  • Node built-ins stay blocked even if listed
  • Compile fails early with a clear error when a built-in is listed

Note: config shape/naming mirrors the issue's proposal. Happy to adjust, and I left docs out until it's confirmed.

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 5 files

Confidence score: 2/5

  • In packages/cli/lib/zeroYaml/compile.ts, allowing bundleDependencies to include Node built-ins appears to bypass the sandbox import policy, which could let restricted modules be imported at runtime and weaken isolation/security guarantees if merged as-is — validate bundleDependencies as true package deps (and explicitly reject Node built-ins) before merging.

Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.

Re-trigger cubic

Comment thread packages/cli/lib/zeroYaml/compile.ts
@sahilnyk
sahilnyk force-pushed the feat/compile-bundle-dependencies branch from 5f6c37e to 85d0e80 Compare July 15, 2026 18:29
Signed-off-by: sahilnyk <contactsahilpnayak@gmail.com>
@sahilnyk
sahilnyk force-pushed the feat/compile-bundle-dependencies branch from d9d6307 to bd8b65d Compare July 15, 2026 19:36
@hassan254-prog
hassan254-prog requested a review from a team July 16, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support bundling workspace/internal dependencies in zero-yaml compile (monorepo)

2 participants